import request from '@/utils/request';

/**
 * 活动列表
 * @param query 
 * @returns 
 */
export const listPage = (query) => {
  return request({
    url: '/activity/list',
    method: 'get',
    params: query
  });
};

/**
 * 活动详情
 * @param query 
 * @returns 
 */
export const info = (query) => {
  return request({
    url: `/activity/detail/${query.id}`,
    method: 'get',
    // params: {
    //   id: query.id
    // }
  });
};

/**
 * 活动使用记录
 * @param query 
 * @returns 
 */
export const useInfoApi = (query) => {
  return request({
    url: `/activity/store/${query.path.id}`,
    method: 'get',
    params: query.query
  });
};
// 用户参与活动
export const useInfoTwoApi = (query) => {
  return request({
    url: `/activity/user/${query.path.id}`,
    method: 'get',
    params: query.query
  });
};

// 新增
export const add = (query) => {
  return request({
    url: `/activity`,
    method: 'post',
    data: query
  });
};

// 编辑
export const edit = (query) => {
  return request({
    url: `/activity`,
    method: 'put',
    data: query
  });
};

// 上下架
export const changeStatusApi = (query) => {
  return request({
    url: `/activity/enable/${query.id}`,
    method: 'put',
  });
};

// 删除
export const del = (query) => {
  return request({
    url: `/activity/remove/${query.id}`,
    method: 'delete',
  });
};

// 兑换奖品
export const duiHuan = (query) => {
  return request({
    url: `/activity/exchange`,
    method: 'post',
    data: query
  });
};